package cn.yhp.mybatis.builder;

import cn.yhp.mybatis.session.Configuration;
import cn.yhp.mybatis.type.TypeAliasRegistry;
import cn.yhp.mybatis.type.TypeHandlerRegistry;

import java.util.ArrayList;

/**
 * 构建器的基类
 * @author yhp
 * @date 2023/11/18
 */
public abstract class BaseBuilder {

    protected final Configuration configuration;

    protected final TypeAliasRegistry typeAliasRegistry;

    protected final TypeHandlerRegistry typeHandlerRegistry;

    public BaseBuilder(Configuration configuration){
        this.configuration=configuration;
        this.typeAliasRegistry= configuration.getTypeAliasRegistry();
        this.typeHandlerRegistry=configuration.getTypeHandlerRegistry();
    }

    public Configuration getConfiguration(){
        return configuration;
    }

    /**
     * 解析别名，拿到对应的class对象
     * @param alias
     * @return
     */
    protected Class<?> resolveAlias(String alias) {
        return typeAliasRegistry.resolveAlias(alias);
    }

}
